package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.BatchBom;
import com.indusfo.spc.service.BatchBomService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author liub
 * @Date 2019/12/5 14:04
 * @Version 1.0
 */

@Controller
@RequestMapping(value = "/service/batchBom")
public class BatchBomController {

    @Autowired
    private BatchBomService batchBomService;

    /**
     * 查询
     */
    @RequestMapping(value = "/queryBatchBom")
    @ResponseBody
    public JSONObject queryBatchBom(BatchBom batchBom) {
        JSONObject json = batchBomService.queryBatchBom(batchBom);
        return json;
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/insertBatchBom", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject insertBatchBom(BatchBom batchBom) {
        JSONObject json = batchBomService.insertBatchBom(batchBom);
        return json;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/updateBatchBom", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject updateBatchBom(BatchBom batchBom) {
        JSONObject json = batchBomService.updateBatchBom(batchBom);
        return json;
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/deleteBatchBom", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject deleteBatchBom(@RequestParam("batchBomIds") List<Integer> batchBomIds, Integer dataState) {
        dataState = 2;
        JSONObject json = batchBomService.deleteBatchBom(batchBomIds, dataState);
        return json;
    }

    /**
     * 启停
     */
    @RequestMapping(value = "/definedBatchBom", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject definedBatchBom(@RequestParam("batchBomIds") List<Integer> batchBomIds, Integer dataState) {
        JSONObject json = batchBomService.deleteBatchBom(batchBomIds, dataState);
        return json;
    }

}
